﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="UsageInfo.aspx.cs" Inherits="WebFormsSample.UsageInfo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Project description</h2>
    <p>
        The ActivityTrackingLog is a pluggable component intended to provide user and system
        activity tracking functions for ASP.Net/MVC applications. Represents a set of HTTP
        handlers and modules that expose activity logging functions along with activity
        analytics UI and client API.<br />
        Easy to configure and use - add ActivityTrackingLog.dll as a reference to your project,
        copy default configutaion from sample project, call Log.LogActivity(...) from your
        page and you are done!
    </p>
    <h2>
        Usage</h2>
    <p>
        The image below presents supported logging scenarious.
    </p>
    <p>
        <img class="width450" src="../Img/usage.PNG" />
    </p>
    <h2>
        Collected Data</h2>
    <table class="image-table">
        <tr>
            <td class="text">
                The data model represents the data being collected by ActivityTrackingLog.
                <ul>
                    <li><span class="bold italic">ActivityItem</span> - stores application activity records.
                        Is mapped to [dbo].[ActivityTrackingLog] database table
                        <ul>
                            <li>Sequence - auto incremental number (populated internally)</li>
                            <li>ActivityLogId - unique identifier (populated internally)</li>
                            <li>ApplicationKey - current application name (taken from log/applicationKey config
                                value)</li>
                            <li>ActivityType - ServerSide, ClientSide, System (populated internally)</li>
                            <li>Category - activity category (provided by log caller)</li>
                            <li>ActivityCode - activity code (provided by log caller)</li>
                            <li>Activity - activity name (provided by log caller)</li>
                            <li>IsPostAction - indicates if activity happened in a post action or after action (provided
                                by log caller)</li>
                            <li>UserKey - currently logged in user name or NULL if user not known (populated internally)</li>
                            <li>ClientHost - caller PC IP address or name (populated internally)</li>
                            <li>PageUrl - logged page partial URL (populated internally)</li>
                            <li>QueryString - query params (populated internally)</li>
                            <li>TimeUtc - UTC date and time at the moment when activity happen (populated internally)</li>
                            <li>UserAgentId - foreign key to browser user agent info (populated internally)</li>
                        </ul>
                    </li>
                    <li class="margin-top"><span class="bold italic">UserAgentItem</span> - stores user
                        agent records . Is mapped to [dbo].[ActivityTrackingUserAgent] database table.
                        <br />
                        <span class="bold">Note:</span>This table keeps unique values by met User Agent
                        string.</li>
                </ul>
            </td>
            <td class="image">
                <img alt="Data Domain" src="Img/Domain.PNG" />
            </td>
        </tr>
    </table>
    <p>
        Pages generate next types of activity actions:
    </p>
    <ul>
        <li><span class="bold italic">Server Side</span> - by calling Log component directly
            from C#/VB code. you can find sample usage in the code behind of Default.aspx</li>
        <li><span class="bold italic">Client Side</span> - by calling atLog proxy object registered
            at page start-up in document DOM. You can find the sample usage in the code &lt;script&gt;
            section of Default.aspx layout</li>
        <li><span class="bold italic">System</span> - collected by SystemEventsLoggingModule
            configured in web.config</li>
    </ul>
    <h2>
        Components</h2>
    <p>
        The image below presents main classes of ActivityTrackingLog separated by functional
        areas.
    </p>
    <p>
        <img class="max-width" src="../Img/class_diagram.PNG" />
    </p>
    <ul>
        <li><span class="bold italic">Log</span> (ActivityTrackingLog.Utils.Log) - Incapsulates
            the core logging functionality. Exposes static logging methods to use from your
            code. Iteracts with storage component.</li>
        <li class="margin-top"><span class="bold italic">Storage</span> - Currently supported
            2 types of storage:
            <ol>
                <li>InMemory (ActivityTrackingLog.Storage.Implementations.InMemoryRepository) - stores
                    all logged data in application's memory. All statistics are lost after application
                    is restarted or shut down. The only way to limit data in size is to configure <span
                        class="bold">oldestDate</span> or <span class="bold">recordsLimit</span>
                </li>
                <li>Linq to SQL (ActivityTrackingLog.Storage.Implementations.L2SqlRepository) - an MSSQL
                    based storage. Is more reliable since it keeps statistics even after the application
                    is restarted.</li>
            </ol>
        </li>
        <li class="margin-top"><span class="bold italic">Client Side Proxy</span> (ActivityTrackingLog.Web.Handlers.ClientSideLogClient)
            - This http handler provides a javascript proxy class (variable name <span class="bold italic">
                atLog</span>) for client side logging. Has to be attached to your page as external
            script file. The output content type is text/javascript.</li>
        <li class="margin-top"><span class="bold italic">UI</span> (ActivityTrackingLog.Web.Handlers.AnalyticsUI)
            - This http handler provides activity analitics in two different groups of UI screens.
            Both groups support 3 types of data presentation: <span class="bold italic">Flat List</span>
            (ReportType=List), <span class="bold italic">Grouped List</span> (ReportType=GroupedList),
            <span class="bold italic">Chart</span> (ReportType=Chart) (Planned feature). The
            output content type is text/html.
            <ol>
                <li><span class="bold italic">Standalone Statistics Pages</span> (ViewType=Page) - This
                    group of reports runs out of the box without any need to created your own UI. All
                    report settings are transmitted by query string parameters. The pages from this
                    group use their own styles however you can refuse using them but you cannot attach
                    your styles.</li>
                <li class="margin-top"><span class="bold italic">Embedded Html Controls</span> (ViewType=Control)
                    - This group of reports requires a custom page to be created in your application.
                    Statistics control is embedded into your page layout preserving your page styles.</li>
            </ol>
        </li>
        <li class="margin-top"><span class="bold italic">API</span> (ActivityTrackingLog.Web.Handlers.AnalyticsApi)
            - This http handler returns statistics data as JSON serialized objects. Supports
            next data presentation types: Flat List, Grouped List. The output content type is
            application/json.</li>
        <li class="margin-top"><span class="bold italic">SystemEventsLogging</span> (ActivityTrackingLog.Web.SystemEventsLoggingModule)
            - This http module logs a subset of server side page life cycle events. These events
            appear as System activity records in database. Useful for debugging/tracing, however
            it doesn't replace standard debugging/tracing functionalities. For best performance
            disable this module in production environment.</li>
    </ul>
    <h2>
        Configuration</h2>
    <p>
        Below presented parts of web.config required to configure activity tracking in your
        application.
    </p>
    <ul>
        <li><span class="bold italic">Section Group Definition</span>
            <img class="max-width" src="Img/config_section_group.PNG" />
        </li>
        <li><span class="bold italic">Settings</span>
            <img class="max-width" src="Img/config_section_settings.PNG" />
        </li>
        <li><span class="bold italic">Handlers configuration</span>
            <img class="max-width" src="Img/handlers_settings.PNG" />
        </li>
        <li><span class="bold italic">Modules Configuration</span>
            <img class="max-width" src="Img/modules_settings.PNG" />
        </li>
    </ul>
    <script type="text/javascript">
        $(function () {
            logClientSideActivity('UsageInfoLoaded');
        })
    </script>
</asp:Content>
